Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plane: tail-sitter interpolate gains with airspeed and enable Q_Assist #9167

Closed
wants to merge 2 commits into from

Conversation

IamPete1
Copy link
Member

@IamPete1 IamPete1 commented Aug 9, 2018

Interpolate Gains between VTOL gains and forward flight gains in Q modes based on airspeed.

Do this based on two new parameters that define the airspeed range at which the change over occurs.

This is a significant improvement at high airspeed although is not perfect. This would benefit from a plane yaw rate controller and body frame rather than earth frame yaw control. Hope to add Q_assist support for this code at some-point so the plane modes can also benefit from this gain interpolation. Also a QAcro mode would be fun.

Significantly adds to the Q modes flight envelope for tail sitters.

Tested in SITL.

https://www.youtube.com/watch?v=4sVT3VI5HDw&feature=youtu.be

@IamPete1
Copy link
Member Author

@IamPete1
Copy link
Member Author

I have reordered the code so it will work as intended for aircraft with forward flight thrust vectoring, And enabled Q_Assist, here is a demo of with Q_Assist and then without.
https://www.youtube.com/watch?v=6MIPEbqxRwE

@IamPete1 IamPete1 changed the title Tail Sitter interpolate gains with airspeed Tail Sitter interpolate gains with airspeed and enable Q_Assist Aug 12, 2018
@robustini
Copy link
Contributor

Nice improvement!

@IamPete1
Copy link
Member Author

Have rebased, tidyed and squashed this

@OXINARF OXINARF requested a review from tridge September 24, 2018 17:48
@IamPete1 IamPete1 force-pushed the Gain_interp branch 4 times, most recently from d38f6b7 to ca27d31 Compare September 25, 2018 17:14
@tridge tridge self-assigned this Oct 1, 2018
@IamPete1
Copy link
Member Author

IamPete1 commented Oct 6, 2018

@tridge , the model and params used in the realflight testing are here https://drive.google.com/open?id=17ZE85aQV1TUw1uq4aDS20j2ThS9BD-fI

Thanks

hal.util->get_soft_armed() &&
((plane.auto_throttle_mode && !plane.throttle_suppressed) ||
plane.get_throttle_input()>0 ||
plane.is_flying())) {
// the quad should provide some assistance to the plane
if (transition_state != TRANSITION_AIRSPEED_WAIT) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change seems to have no effect, why change it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to enable assisted flight for tail sitters without entering airspeed wait transition state

const float throttle = motors->get_throttle() * 100;
const float rud_gain = float(plane.g2.rudd_dt_gain) / 100;

// Calculate differential thrust in forward flight
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is all of this commented out?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

originally it was there so it could be un-commented when plane got a yaw rate controller. I'm in the process of a rebase and tidy up.

@magicrub
Copy link
Contributor

magicrub commented Feb 3, 2019

@kd0aij would you mind taking a look at this?

@IamPete1 IamPete1 added the WIP label Feb 3, 2019
@IamPete1 IamPete1 changed the title Tail Sitter interpolate gains with airspeed and enable Q_Assist plane: tail-sitter interpolate gains with airspeed and enable Q_Assist Feb 3, 2019
@IamPete1
Copy link
Member Author

IamPete1 commented Feb 3, 2019

this now includes #10381

I have rebased and tidyed now is working as it should, @magicrub would be great if you could have another look.

This significantly adds to the flight envelope of all modes for tailsitters. With one or two things that might catch you out. One is flying high alpha in FBWA, it works fine however the roll limit is for forward flight is still used so roll is much more twitchy than it would be at a equivalent angle in a Q mode. The second issue is going fast in Q modes, this locks you into the plane controller and it can sometimes get stuck in the plane controller attempting to reach a impossible angle. In both cases lots of throttle will help. I think both are also not helped by being at the extreme range of the euler angles for each mode. Also i suspect in real life you would be rather more cautious than i have been in SITL testing so may be very unlikely to happen at all.
TLDR: flight envelope is bigger but care must still be taken near the limits.

Plane modes don't really take advantage of the new high alpha capability because the don't know that at high alphas throttle is used for altitude control rather than pitch.

@kd0aij Would be great if you could take a look, I will probably add this to your copter tailsitter branch and have a play myself soon.

@IamPete1 IamPete1 removed the WIP label Feb 3, 2019
@kd0aij
Copy link
Contributor

kd0aij commented Feb 3, 2019

@IamPete1 I tried flying the AddictionX in RF8: OK in FBWA, but as soon as I switch to QHOVER, it crashes with backtrace reporting "no stack" in gdb. This is similar behavior to what I was getting with one of my recent PRs, but I never found the cause.
I checked out your Gain_interp branch: acb3b1b14752

@IamPete1
Copy link
Member Author

IamPete1 commented Feb 3, 2019

@kd0aij odd, working fine for me, the only thing that would cause it to crash is having the new parameters equal. This gives a divide by zero that is not checked... opoos i see i have set the defaults so they are equal.

@IamPete1
Copy link
Member Author

IamPete1 commented Feb 3, 2019

@kd0aij try that, have changed the defaults and added a divide by zero check.
As a rule of thumb you should tune Q modes for hover and then set the min scailing range to slightly lower than speed than the speed wobbles come on. And then set the max and Q_assist speed to FBW min speed or slightly above

ArduPlane/tailsitter.cpp Outdated Show resolved Hide resolved
@kd0aij
Copy link
Contributor

kd0aij commented Feb 3, 2019

that fixed the crash, running qautotune on the AddictionX now...

Have you tried the AddictionX? After running qautotune, I have to set spdmin to zero to see an effect in qhover. spdmax is at 10

@IamPete1
Copy link
Member Author

IamPete1 commented Feb 9, 2019

@kd0aij I have just got round to trying the Addiction X, its has such big control surfaces and light weight it doesn't benefit much from this, if it had a bigger motor and could go faster i think you would start to see a difference. It benefits from adding rudder to the throttle scaling.

I have cherry picked your quad tail-sitter stuff on on top of this here https://github.com/IamPete1/ardupilot/tree/gain_interp_quad makes a huge difference on the striker in Q modes, can fly straight up at full throttle after a auto tune. Interestingly it failed to auto tune yaw, i think the removal of motor torque yawing means it did't finish, probably would have if i had lowered the aggressiveness. Again not such a benefit in forwards flight due to the delta wing already being good at high alpha, does kick on the throttles of the top and bottom motors tho.

@kd0aij
Copy link
Contributor

kd0aij commented Mar 5, 2019

@IamPete1 Do the PID controllers for plane use gains the same as the copter controller, i.e. does a gain of 0.5 result in the same rate loop gain for both? I assume that's true since you're interpolating between them, but I haven't looked at the plane controllers yet.

@IamPete1
Copy link
Member Author

IamPete1 commented Mar 5, 2019

@kd0aij no the gains don't directly scale. This runs both control loops and interpolates the outputs.

@kd0aij
Copy link
Contributor

kd0aij commented Mar 5, 2019

That makes sense. I was reading the PR title too literally, and didn't realize that both controllers are running at the same time. I guess the PID controller CPU cost is not significant.


if (assisted_flight) {
control_stabilize();
motors_output(true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're calling motors_output more than once in each pass through set_servos, right?
The option to not run the rate controller is to make the multiple calls less inefficient?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is for Q-assist, it we're in a normal vtol mode this is already done in the quadplane code, altough i'm not sure why I need to call control stabalise again

@IamPete1
Copy link
Member Author

IamPete1 commented Mar 10, 2019

@kd0aij I'm struggling to make any improvement on this by use of the yaw dammper. I'm beginning to think I'm asking too much for the airframe, to sort of knife edge and yaw up to vertical. Once its going fast full throttle on one motor and the other stopped is not enough to overpower the rudder not moving enough. My tvbs is quite unusual tho in that it actually has a rudder it might be fine for wings.

@kd0aij
Copy link
Contributor

kd0aij commented Mar 10, 2019 via email

@IamPete1
Copy link
Member Author

@kd0aij https://github.com/IamPete1/ardupilot/tree/Gain_intep_yaw I havent pushed it here yet

@kd0aij
Copy link
Contributor

kd0aij commented Mar 10, 2019

It's definitely an airframe limitation; you need to be able to do a knife-edge loop to recover using rudder only. Roman Bapst implemented a recovery technique (for PX4) which first rolls level, then pitches up. That can happen very fast... There's actually an academic paper on the technique, from ETH Zurich, I think.
This is one reason I'm exploring quad tailsitters, but I haven't managed a knife-edge loop with the Stryker_quad yet :( I think it should have enough lateral area to do it though.

@IamPete1
Copy link
Member Author

IamPete1 commented Mar 10, 2019

@kd0aij Thats good to know I guess, can you have a fly of this branch with these params https://github.com/ArduPilot/SITL_Models/blob/quad_TS/RealFlight/markw/Tailsitters/QuadMotorTailsitters/Stryker/matrixTS_ptun%20gain%20scailing.parm The Q gains are straight from auto tune, would be interested to hear what you think. (just did a knife edge loop in Qacro, not very tidy tho more of a oval)

@peterbarker
Copy link
Contributor

@IamPete1 I'm guessing the tailsitter code has moved on significantly since this PR was created.

Do you see any value in leaving this PR open?

@IamPete1
Copy link
Member Author

IamPete1 commented Dec 5, 2020

@peterbarker I do have fairly recent rebase of this, as in this year, I do think this would be better, but hopefully #15719 will be close.

Not much chance of getting back to this unless some keen testers turn up, I will close.

@IamPete1 IamPete1 closed this Dec 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Plane Backports
Awaiting triage
Development

Successfully merging this pull request may close these issues.

None yet

9 participants